{% extends "agmstaff/index.html" %}
{% block title %}英宝公司-{{keyword}}区{% endblock %}
{% block title0 %}英宝公司-{{keyword}}区{% endblock %}
{% set states = ['未处理', '处理中', '处理完成']%}
{% block otherstyle %}
table {
  margin: 1rem 0;
  max-width: 100%;
  width: 100%; }
  table th,
  table td {
    padding: 0.5rem;
    text-align: left;
    vertical-align: top; }
    [dir="rtl"] table th, [dir="rtl"]
    table td {
      text-align: right; }
    .table-striped tbody > tr:nth-child(odd) > td,
    .table-striped tbody > tr:nth-child(odd) > th {
      background-color: #ebebeb; }
   th{
      background-color:black;
      color:white;
   }   
   .toggle{
      display:none;
   }
{% endblock %}
{% block page_bd %}
<div style="text-align:right">
                {% if isadmin %}
    <a href="javascript:;" class="weui-btn weui-btn_mini weui-btn_warn showbtn">显示</a>
                {% endif %}
    <a href="." class="weui-btn weui-btn_mini weui-btn_default">返回</a>
    <a href="{{link}}" class="weui-btn weui-btn_mini weui-btn_primary">新增</a>
</div>
<div style="overflow-x:auto;white-space:nowrap;">
    <table class="table-striped">
        <thead>
            <tr>
                <th>{{ keyword }}编号</th>
                <th>状态</th>
                <th>处理人</th>
                <th>{{ keyword }}时间</th>
                {% if isadmin %}
                <th class="toggle">{{ keyword }}人</th>
                <th class="toggle">所在部门</th>
                <th class="toggle">电话</th>
                <th class="toggle">{{ keyword }}对象</th>
                <th class="toggle">{{ keyword }}内容</th>
                <th class="toggle">处理设置</th>
                {% endif %}
            </tr>
        </thead>
        <tbody>
            {% for report in reports %}
            <tr>
                <td>{{ printDateTime(report.created_at, '%Y%m%d%H%M%S')}}{{ report.id[-3:] }}</td>
                <td>{{ states[report.get('state')] }}</td>
                <td>{{ report.get('dealName') or '暂无' }}</td>
                <td>{{ printDateTime(report.created_at, '%Y%m%d %H:%M') }}</td>
                {% if isadmin %}
                <td class="toggle">{{ report.get('name')}}</td>
                <td class="toggle">{{ report.get('depart')}}</td>
                <td class="toggle">{{ report.get('phone')}}</td>
                <td class="toggle">{{ report.get('report_type')}}</td>
                <td class="toggle">{{ report.get('des')}}</td>
                <td class="toggle">{% if report.get('state') < 2 %}<a href="javascript:setState({{ report.get('state') }},'{{ report.id }}');" class="weui-btn weui-btn_mini weui-btn_primary">{{ states[report.get('state')+1 ]}}</a>{% else %}<a href="javascript:;" class="weui-btn weui-btn_mini weui-btn_primary weui-btn_disabled">无操作</a>{% endif %}</td>
                {% endif %}
            </tr>
            {% endfor %}
        </tbody>
    </table>
</div>
{% endblock %}
{% block otherscript %}
setState = function(s, i){
$.post("?state="+s+"&rid="+i, function(data){
    console.info(data);
    if(data=='success'){
        location.reload();
    }
})
}
$(document).on('click', '.showbtn', function(){
    var self = $(this);
    self.removeClass('showbtn').addClass('hidebtn');
    self.text('隐藏');
    $('.toggle').show();
})
$(document).on('click', '.hidebtn', function(){
    var self = $(this);
    self.removeClass('hidebtn').addClass('showbtn');
    self.text('显示');
    $('.toggle').hide();
})
{% endblock %}
